//
//  YSYNavigationController.m
//  YSYUISateRestorationDemo
//
//  Created by muxue on 2019/9/27.
//  Copyright © 2019 暮雪. All rights reserved.
//

#import "YSYNavigationController.h"

@interface YSYNavigationController ()

@end

@implementation YSYNavigationController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.restorationIdentifier = NSStringFromClass(self.class);
}

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated {
    if (self.viewControllers.count > 0) {
        // 导航栏都是栈管理的 当栈里面的内容大于0 说明push了
        // 自定义了tabbar会自动控制显示和隐藏，并且系统tabbar最开始时已经隐藏，所以这边不需要再处理了
        // 隐藏tableBar
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion {
    if (self.viewControllers.count > 0) {
        viewControllerToPresent.hidesBottomBarWhenPushed = YES;
    }
    [super presentViewController:viewControllerToPresent animated:flag completion:completion];
}

- (void)decodeRestorableStateWithCoder:(NSCoder *)coder {
    [super decodeRestorableStateWithCoder:coder];
    NSLog(@"[%@ decodeRestorableStateWithCoder]", NSStringFromClass(self.class));
}

- (void)encodeRestorableStateWithCoder:(NSCoder *)coder {
    [super encodeRestorableStateWithCoder:coder];
    NSLog(@"[%@ encodeRestorableStateWithCoder]", NSStringFromClass(self.class));
}

@end
